package orm;

import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Collection;


public class SessionFactory {
    private static void setParam(PreparedStatement ps,Object[] p){
    if(p==null ||p.length ==0){
        return;
    }
        for (int i = 0; i < p.length; i++) {
            try {
                if (p[i] instanceof String) {
                    ps.setString(i + 1, (String) p[i]);
                }else   if (p[i] instanceof Integer) {
                    ps.setInt(i + 1, (Integer) p[i]);
                }else  if (p[i] instanceof Double) {
                    ps.setDouble(i + 1, (Double) p[i]);
                }else  if (p[i] instanceof Date) {
                    ps.setDate(i + 1, (Date) p[i]);
                }else  if (p[i] instanceof Boolean) {
                    ps.setBoolean(i + 1, (Boolean) p[i]);
                }
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }

    public static <T>T execSel(SqlTask t,Class returnT,Class resT){

        Collection<T> c =execSelReturnList(t,Collection.class,resT);
//        Collection<T> c =execSelReturnList(t,returnT,resT);
    }

    private static <T> Collection<T> execSelReturnList(SqlTask t, Class<Collection> collectionClass, Class resT) {
        connProxy

    }
}
